{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import pandas as pd "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(23, 12384)\n",
      "(23, 5184)\n"
     ]
    }
   ],
   "source": [
    "workday_file = '/Users/gengyunxin/Documents/项目/traffic_model/TVTS_9.28/data/combine_E_workday_n0.csv'\n",
    "weekend_file = '/Users/gengyunxin/Documents/项目/traffic_model/TVTS_9.28/data/combine_E_weekend_n0.csv'\n",
    "df_workday = pd.read_csv(workday_file).values.transpose()#(23,12384)\n",
    "df_weekend = pd.read_csv(weekend_file).values.transpose()#(23,5184)\n",
    "print(df_workday.shape)\n",
    "print(df_weekend.shape)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "road: 0\n",
      "max:  400\n",
      "min:  3\n",
      "length:  12384\n",
      "road: 1\n",
      "max:  425\n",
      "min:  7\n",
      "length:  12384\n",
      "road: 2\n",
      "max:  568\n",
      "min:  13\n",
      "length:  12384\n",
      "road: 3\n",
      "max:  543\n",
      "min:  18\n",
      "length:  12384\n",
      "road: 4\n",
      "max:  705\n",
      "min:  23\n",
      "length:  12384\n",
      "road: 5\n",
      "max:  527\n",
      "min:  28\n",
      "length:  12384\n",
      "road: 6\n",
      "max:  623\n",
      "min:  31\n",
      "length:  12384\n",
      "road: 7\n",
      "max:  654\n",
      "min:  20\n",
      "length:  12384\n",
      "road: 8\n",
      "max:  670\n",
      "min:  23\n",
      "length:  12384\n",
      "road: 9\n",
      "max:  632\n",
      "min:  21\n",
      "length:  12384\n",
      "road: 10\n",
      "max:  519\n",
      "min:  23\n",
      "length:  12384\n",
      "road: 11\n",
      "max:  412\n",
      "min:  24\n",
      "length:  12384\n",
      "road: 12\n",
      "max:  430\n",
      "min:  23\n",
      "length:  12384\n",
      "road: 13\n",
      "max:  683\n",
      "min:  40\n",
      "length:  12384\n",
      "road: 14\n",
      "max:  634\n",
      "min:  37\n",
      "length:  12384\n",
      "road: 15\n",
      "max:  508\n",
      "min:  39\n",
      "length:  12384\n",
      "road: 16\n",
      "max:  512\n",
      "min:  46\n",
      "length:  12384\n",
      "road: 17\n",
      "max:  498\n",
      "min:  35\n",
      "length:  12384\n",
      "road: 18\n",
      "max:  466\n",
      "min:  5\n",
      "length:  12384\n",
      "road: 19\n",
      "max:  600\n",
      "min:  14\n",
      "length:  12384\n",
      "road: 20\n",
      "max:  758\n",
      "min:  1\n",
      "length:  12384\n",
      "road: 21\n",
      "max:  360\n",
      "min:  16\n",
      "length:  12384\n",
      "road: 22\n",
      "max:  370\n",
      "min:  22\n",
      "length:  12384\n",
      "(989, 288)\n",
      "(989, 1)\n",
      "(989, 289)\n"
     ]
    }
   ],
   "source": [
    "# (989, 289)\n",
    "raw_workday = []\n",
    "for road in range(df_workday.shape[0]):\n",
    "    print('road:', road)\n",
    "    road_ts = df_workday[road]\n",
    "    max = road_ts.max()\n",
    "    min = road_ts.min()\n",
    "    print('max: ', max)\n",
    "    print('min: ', min)\n",
    "    norm_road_ts = ((road_ts - min) / (max - min)).tolist()\n",
    "    print('length: ', len(norm_road_ts))\n",
    "    raw_workday.append(norm_road_ts)\n",
    "raw_workday_array = np.array(raw_workday).reshape(-1, 288)\n",
    "print(raw_workday_array.shape)\n",
    "label = np.ones((int(df_workday.shape[1] * df_workday.shape[0] / 288), 1))\n",
    "print(label.shape)\n",
    "workday_array = np.hstack((raw_workday_array, label))\n",
    "print(workday_array.shape)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "road: 0\n",
      "max:  290\n",
      "min:  13\n",
      "length:  5184\n",
      "road: 1\n",
      "max:  351\n",
      "min:  18\n",
      "length:  5184\n",
      "road: 2\n",
      "max:  538\n",
      "min:  31\n",
      "length:  5184\n",
      "road: 3\n",
      "max:  504\n",
      "min:  29\n",
      "length:  5184\n",
      "road: 4\n",
      "max:  683\n",
      "min:  56\n",
      "length:  5184\n",
      "road: 5\n",
      "max:  488\n",
      "min:  31\n",
      "length:  5184\n",
      "road: 6\n",
      "max:  541\n",
      "min:  59\n",
      "length:  5184\n",
      "road: 7\n",
      "max:  638\n",
      "min:  57\n",
      "length:  5184\n",
      "road: 8\n",
      "max:  657\n",
      "min:  58\n",
      "length:  5184\n",
      "road: 9\n",
      "max:  587\n",
      "min:  48\n",
      "length:  5184\n",
      "road: 10\n",
      "max:  470\n",
      "min:  10\n",
      "length:  5184\n",
      "road: 11\n",
      "max:  393\n",
      "min:  10\n",
      "length:  5184\n",
      "road: 12\n",
      "max:  397\n",
      "min:  20\n",
      "length:  5184\n",
      "road: 13\n",
      "max:  700\n",
      "min:  55\n",
      "length:  5184\n",
      "road: 14\n",
      "max:  540\n",
      "min:  48\n",
      "length:  5184\n",
      "road: 15\n",
      "max:  510\n",
      "min:  48\n",
      "length:  5184\n",
      "road: 16\n",
      "max:  489\n",
      "min:  54\n",
      "length:  5184\n",
      "road: 17\n",
      "max:  406\n",
      "min:  59\n",
      "length:  5184\n",
      "road: 18\n",
      "max:  450\n",
      "min:  14\n",
      "length:  5184\n",
      "road: 19\n",
      "max:  475\n",
      "min:  22\n",
      "length:  5184\n",
      "road: 20\n",
      "max:  617\n",
      "min:  39\n",
      "length:  5184\n",
      "road: 21\n",
      "max:  283\n",
      "min:  23\n",
      "length:  5184\n",
      "road: 22\n",
      "max:  297\n",
      "min:  10\n",
      "length:  5184\n",
      "(414, 288)\n",
      "(414, 1)\n",
      "(414, 289)\n",
      "[0.37906137 0.58122744 0.59566787 0.55956679 0.60288809 0.57039711\n",
      " 0.51263538 0.59927798 0.53429603 0.49819495 0.46209386 0.44404332\n",
      " 0.44043321 0.41877256 0.36101083 0.3465704  0.31768953 0.26714801\n",
      " 0.27075812 0.42960289 0.37906137 0.2599278  0.31407942 0.19133574\n",
      " 0.26714801 0.33212996 0.19855596 0.27075812 0.23104693 0.20577617\n",
      " 0.18772563 0.19855596 0.19855596 0.19855596 0.16967509 0.07581227\n",
      " 0.12635379 0.16245487 0.07220217 0.07220217 0.07581227 0.07220217\n",
      " 0.06137184 0.15162455 0.14801444 0.1299639  0.10830325 0.10469314\n",
      " 0.09747292 0.07220217 0.11552347 0.0866426  0.12635379 0.20216606\n",
      " 0.11191336 0.18772563 0.27075812 0.29241877 0.18411552 0.15523466\n",
      " 0.2166065  0.22021661 0.25631769 0.29602888 0.22021661 0.24548736\n",
      " 0.22021661 0.30685921 0.32129964 0.27075812 0.24909747 0.28519856\n",
      " 0.37184116 0.46209386 0.42960289 0.31407942 0.39350181 0.33574007\n",
      " 0.32851986 0.44404332 0.4368231  0.37545126 0.38628159 0.41155235\n",
      " 0.38628159 0.45487365 0.38628159 0.46209386 0.49458484 0.41516245\n",
      " 0.40794224 0.42960289 0.49458484 0.49458484 0.49458484 0.39711191\n",
      " 0.37906137 0.42238267 0.45848375 0.42599278 0.50180505 0.34296029\n",
      " 0.41155235 0.42238267 0.46931408 0.54151625 0.47292419 0.46570397\n",
      " 0.48375451 0.38267148 0.52707581 0.46931408 0.48375451 0.50180505\n",
      " 0.49458484 0.50902527 0.566787   0.58122744 0.47292419 0.4801444\n",
      " 0.44765343 0.55234657 0.50541516 0.53790614 0.61732852 0.54512635\n",
      " 0.5234657  0.63898917 0.46209386 0.63176895 0.59205776 0.51624549\n",
      " 0.61732852 0.55956679 0.67509025 0.52707581 0.63537906 0.53429603\n",
      " 0.55595668 0.58483755 0.59927798 0.57400722 0.48736462 0.60288809\n",
      " 0.60649819 0.75812274 0.566787   0.6534296  0.63898917 0.6101083\n",
      " 0.60288809 0.66787004 0.69314079 0.68592058 0.77978339 0.72563177\n",
      " 0.49097473 0.80866426 0.68592058 0.60288809 0.77617329 0.67148014\n",
      " 0.75090253 0.71841155 0.74729242 0.7833935  0.76534296 0.67148014\n",
      " 0.65703971 0.71480144 0.81949458 0.68231047 0.67870036 0.73285199\n",
      " 0.76895307 0.97111913 0.8267148  0.8267148  0.68953069 0.64620939\n",
      " 0.73285199 0.71480144 0.84476534 0.77617329 0.71841155 0.75451264\n",
      " 0.71480144 0.90252708 0.85198556 0.74729242 0.80866426 0.68592058\n",
      " 0.66425993 0.64620939 0.70397112 0.70758123 0.68592058 0.66425993\n",
      " 0.70397112 0.8267148  0.92418773 0.81949458 0.80505415 0.65703971\n",
      " 0.76534296 0.60288809 0.86642599 0.7400722  0.70036101 0.79783394\n",
      " 0.70036101 0.61371841 0.74368231 0.65703971 0.64620939 0.68231047\n",
      " 0.57400722 0.566787   0.79422383 0.75451264 0.57761733 0.66064982\n",
      " 0.68231047 0.566787   0.55956679 0.46209386 0.57761733 0.49458484\n",
      " 0.55595668 0.68231047 0.6101083  0.6534296  0.59927798 0.5198556\n",
      " 0.5631769  0.62815884 0.62815884 0.57761733 0.53068592 0.47292419\n",
      " 0.5234657  0.54151625 0.62454874 0.55956679 0.60649819 0.46209386\n",
      " 0.55956679 0.59927798 0.58483755 0.58122744 0.60649819 0.49819495\n",
      " 0.5631769  0.57761733 0.6101083  0.63176895 0.54873646 0.62093863\n",
      " 0.55956679 0.57761733 0.64259928 0.66787004 0.67148014 0.64259928\n",
      " 0.55595668 0.70758123 0.7400722  0.67870036 0.68592058 0.61732852\n",
      " 0.60288809 0.62454874 0.58483755 0.48375451 0.64620939 0.66425993\n",
      " 0.6101083  0.6534296  0.64981949 0.58122744 0.49458484 0.53068592\n",
      " 0.46570397 0.49819495 0.42960289 0.55956679 0.46209386 0.49458484\n",
      " 0.        ]\n"
     ]
    }
   ],
   "source": [
    "# (414, 289)\n",
    "raw_weekend = []\n",
    "for road in range(df_weekend.shape[0]):\n",
    "    print('road:', road)\n",
    "    road_ts = df_weekend[road]\n",
    "    max = road_ts.max()\n",
    "    min = road_ts.min()\n",
    "    print('max: ', max)\n",
    "    print('min: ', min)\n",
    "    norm_road_ts = ((road_ts - min) / (max - min)).tolist()\n",
    "    print('length: ', len(norm_road_ts))\n",
    "    raw_weekend.append(norm_road_ts)\n",
    "raw_weekend_array = np.array(raw_weekend).reshape(-1, 288)\n",
    "print(raw_weekend_array.shape)\n",
    "label = np.zeros((int(df_weekend.shape[1] * df_weekend.shape[0] / 288), 1))\n",
    "print(label.shape)\n",
    "weekend_array = np.hstack((raw_weekend_array, label))\n",
    "print(weekend_array.shape) \n",
    "print(weekend_array[0]) "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(593, 289)\n",
      "(198, 289)\n",
      "(198, 289)\n"
     ]
    }
   ],
   "source": [
    "r1 = 0.6\n",
    "r2 = 0.8\n",
    "train_workday = workday_array[:int(workday_array.shape[0]*r1)]\n",
    "valid_workday = workday_array[int(workday_array.shape[0]*r1):int(workday_array.shape[0]*r2)]\n",
    "test_workday = workday_array[int(workday_array.shape[0]*r2):]\n",
    "print(train_workday.shape)\n",
    "print(valid_workday.shape)\n",
    "print(test_workday.shape)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(248, 289)\n",
      "(83, 289)\n",
      "(83, 289)\n"
     ]
    }
   ],
   "source": [
    "train_weekend = weekend_array[:int(weekend_array.shape[0]*r1)]\n",
    "valid_weekend = weekend_array[int(weekend_array.shape[0]*r1):int(weekend_array.shape[0]*r2)]\n",
    "test_weekend = weekend_array[int(weekend_array.shape[0]*r2):]\n",
    "print(train_weekend.shape)\n",
    "print(valid_weekend.shape)\n",
    "print(test_weekend.shape)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(841, 289)\n",
      "(281, 289)\n",
      "(281, 289)\n"
     ]
    }
   ],
   "source": [
    "train = np.vstack((train_workday, train_weekend))\n",
    "valid = np.vstack((valid_workday, valid_weekend))\n",
    "test = np.vstack((test_workday, test_weekend))\n",
    "print(train.shape)\n",
    "print(valid.shape)\n",
    "print(test.shape)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [],
   "source": [
    "np.random.shuffle(train)\n",
    "np.random.shuffle(valid)\n",
    "np.random.shuffle(test)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [],
   "source": [
    "np.savetxt('/Users/gengyunxin/Documents/项目/traffic_model/TVTS_9.28/data/train_classify.csv', train, delimiter=',')\n",
    "np.savetxt('/Users/gengyunxin/Documents/项目/traffic_model/TVTS_9.28/data/valid_classify.csv', valid, delimiter=',')\n",
    "np.savetxt('/Users/gengyunxin/Documents/项目/traffic_model/TVTS_9.28/data/test_classify.csv', test, delimiter=',')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "---"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "def read_data(file_path, label):\n",
    "    num_roads = 24  \n",
    "#     saved_path = '/Users/gengyunxin/Documents/项目/traffic_model/test/data/processed_finetune_seattle_72.csv'\n",
    "    df = pd.read_csv(file_path, names=None).values\n",
    "  \n",
    "    df_T = df.transpose() # (24, 12384)\n",
    "    # 每条样本的长度要综合考虑，不能存在两条道路的数据混合在一条样本中的情况\n",
    "    # 即能被12384整除；\n",
    "    # 还要和小时、天等实际意义挂钩；\n",
    "    # 同时要考虑一条样本（sentence）中“词”的数量要合理\n",
    "    \n",
    "    # 每条路的数据独立做归一化\n",
    "    raw = []\n",
    "    for i in range(num_roads):\n",
    "        array = df_T[i]\n",
    "        max = array.max()\n",
    "        min = array.min()\n",
    "        normalized = ((array - min) / (max - min)).tolist()\n",
    "        raw.append(normalized)\n",
    "\n",
    "    df_norm = np.array(raw)\n",
    "    \n",
    "    data_quarter = df_norm.reshape(-1, 72) # 每条样本72个点,即1/4天 \n",
    "\n",
    "    num_rows = data_quarter.shape[0]\n",
    "    if label == 1:\n",
    "        labels = np.ones((1, num_rows))\n",
    "    else:\n",
    "        labels = np.zeros((1, num_rows))\n",
    "    data_with_label = np.insert(data_quarter, 72, values=labels, axis=1) \n",
    "    \n",
    "    return data_with_label"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "workday_file = '/Users/gengyunxin/Documents/项目/traffic_model/data/California/combine_E_workday_n0.csv'\n",
    "weekend_file = '/Users/gengyunxin/Documents/项目/traffic_model/data/California/combine_E_weekend_n0.csv'\n",
    "# weekday->1 ; weekend->0\n",
    "workday_with_label = read_data(workday_file, label=1) # (4128, 73)\n",
    "weekend_with_label = read_data(weekend_file, label=0) # (1728, 73)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(4128, 73)"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "workday_with_label.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(1728, 73)"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "weekend_with_label.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(5856, 73)"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "all_with_label = np.append(workday_with_label, weekend_with_label, axis=0) # (5856, 73)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [],
   "source": [
    "df = pd.DataFrame(all_with_label)\n",
    "df.to_csv('/Users/gengyunxin/Documents/项目/traffic_model/test/data/processed_finetune_seattle_72.csv', index=0, header=0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2.388888888888889"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "12384/5184"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "---\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Wall time</th>\n",
       "      <th>Step</th>\n",
       "      <th>Value</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1.638359e+09</td>\n",
       "      <td>0</td>\n",
       "      <td>0.704626</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1.638359e+09</td>\n",
       "      <td>1</td>\n",
       "      <td>0.704626</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1.638359e+09</td>\n",
       "      <td>2</td>\n",
       "      <td>0.704626</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1.638359e+09</td>\n",
       "      <td>3</td>\n",
       "      <td>0.704626</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>1.638359e+09</td>\n",
       "      <td>4</td>\n",
       "      <td>0.704626</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>100</th>\n",
       "      <td>1.638360e+09</td>\n",
       "      <td>100</td>\n",
       "      <td>0.843416</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>101</th>\n",
       "      <td>1.638360e+09</td>\n",
       "      <td>101</td>\n",
       "      <td>0.829181</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>102</th>\n",
       "      <td>1.638360e+09</td>\n",
       "      <td>102</td>\n",
       "      <td>0.861210</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>103</th>\n",
       "      <td>1.638360e+09</td>\n",
       "      <td>103</td>\n",
       "      <td>0.807829</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>104</th>\n",
       "      <td>1.638360e+09</td>\n",
       "      <td>104</td>\n",
       "      <td>0.871886</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>105 rows × 3 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "        Wall time  Step     Value\n",
       "0    1.638359e+09     0  0.704626\n",
       "1    1.638359e+09     1  0.704626\n",
       "2    1.638359e+09     2  0.704626\n",
       "3    1.638359e+09     3  0.704626\n",
       "4    1.638359e+09     4  0.704626\n",
       "..            ...   ...       ...\n",
       "100  1.638360e+09   100  0.843416\n",
       "101  1.638360e+09   101  0.829181\n",
       "102  1.638360e+09   102  0.861210\n",
       "103  1.638360e+09   103  0.807829\n",
       "104  1.638360e+09   104  0.871886\n",
       "\n",
       "[105 rows x 3 columns]"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "file = '/Users/gengyunxin/Documents/项目/traffic_model/TVTS_9.28/loss/classification/288new/GRU_val_acc.csv'\n",
    "df = pd.read_csv(file)\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Wall time</th>\n",
       "      <th>Step</th>\n",
       "      <th>Value</th>\n",
       "      <th>Percentage</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1.638359e+09</td>\n",
       "      <td>0</td>\n",
       "      <td>0.704626</td>\n",
       "      <td>70.462632</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1.638359e+09</td>\n",
       "      <td>1</td>\n",
       "      <td>0.704626</td>\n",
       "      <td>70.462632</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1.638359e+09</td>\n",
       "      <td>2</td>\n",
       "      <td>0.704626</td>\n",
       "      <td>70.462632</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1.638359e+09</td>\n",
       "      <td>3</td>\n",
       "      <td>0.704626</td>\n",
       "      <td>70.462632</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>1.638359e+09</td>\n",
       "      <td>4</td>\n",
       "      <td>0.704626</td>\n",
       "      <td>70.462632</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>100</th>\n",
       "      <td>1.638360e+09</td>\n",
       "      <td>100</td>\n",
       "      <td>0.843416</td>\n",
       "      <td>84.341639</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>101</th>\n",
       "      <td>1.638360e+09</td>\n",
       "      <td>101</td>\n",
       "      <td>0.829181</td>\n",
       "      <td>82.918149</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>102</th>\n",
       "      <td>1.638360e+09</td>\n",
       "      <td>102</td>\n",
       "      <td>0.861210</td>\n",
       "      <td>86.120999</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>103</th>\n",
       "      <td>1.638360e+09</td>\n",
       "      <td>103</td>\n",
       "      <td>0.807829</td>\n",
       "      <td>80.782920</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>104</th>\n",
       "      <td>1.638360e+09</td>\n",
       "      <td>104</td>\n",
       "      <td>0.871886</td>\n",
       "      <td>87.188613</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>105 rows × 4 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "        Wall time  Step     Value  Percentage\n",
       "0    1.638359e+09     0  0.704626   70.462632\n",
       "1    1.638359e+09     1  0.704626   70.462632\n",
       "2    1.638359e+09     2  0.704626   70.462632\n",
       "3    1.638359e+09     3  0.704626   70.462632\n",
       "4    1.638359e+09     4  0.704626   70.462632\n",
       "..            ...   ...       ...         ...\n",
       "100  1.638360e+09   100  0.843416   84.341639\n",
       "101  1.638360e+09   101  0.829181   82.918149\n",
       "102  1.638360e+09   102  0.861210   86.120999\n",
       "103  1.638360e+09   103  0.807829   80.782920\n",
       "104  1.638360e+09   104  0.871886   87.188613\n",
       "\n",
       "[105 rows x 4 columns]"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "value = df['Value'] * 100\n",
    "df['Percentage'] = value\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "df.to_csv(file)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "768.0"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "288*64/24"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python [conda env:pytorch1.6.0] *",
   "language": "python",
   "name": "conda-env-pytorch1.6.0-py"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
